import React from 'react';
import { Table } from 'antd';
import moment from 'moment';
import fx from '../../investmentAnalysis/utils/fx';
import dicts from '../../investmentAnalysis/dicts';

const columns = [
  {
    title: '股票代码',
    dataIndex: 'symbol',
  },
  {
    title: '类型',
    dataIndex: 'tradeType',
    render: text => dicts.tradeType[text],
  },
  {
    title: '价格',
    dataIndex: 'price',
    render: text => fx.formatNumber(text, 2),
  },
  {
    title: '交易数量',
    dataIndex: 'quantity',
  },
  {
    title: '费用',
    dataIndex: 'fee',
    render: text => fx.formatNumber(text, 2),
  },
  {
    title: '建仓时间',
    dataIndex: 'timestamp',
    render: text => moment(new Date(text)).format('YYYY-MM-DD HH:mm'),
  },
];

export default ({ list }) => (
  <dl>
    <dt>持仓列表</dt>
    <dd>
      <Table
        size="middle"
        dataSource={list}
        columns={columns}
      />
    </dd>
  </dl>);
